package universalcopy;

import core.transfer.Transfer;
import java.io.File;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreeSelectionModel;

import core.exceptions.*;

/**
 * Class Launcher : This is the entry point of the application
 * @project Universalcopy
 * @author Aurele TONNERRE, Romain Monnier
 */
public class Launcher extends javax.swing.JFrame {

    /**
     * Creates new form Launcher
     */
    public Launcher() {
        
        this.launcher = this;
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jSeparator1 = new javax.swing.JSeparator();
        JTBSource = new javax.swing.JTabbedPane();
        jPanelLocal = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        DefaultMutableTreeNode racine = new DefaultMutableTreeNode();
        int count = 0;

        for(File file : File.listRoots()) {

            String f= file.getAbsolutePath();
            DefaultMutableTreeNode lecteur = new DefaultMutableTreeNode(f);
            System.out.println(f);
            //if(f.equals(s)){

                try {
                    for(File nom : file.listFiles()){

                        DefaultMutableTreeNode node = new DefaultMutableTreeNode(nom.getName()+ java.io.File.separator);
                        lecteur.add(listFile(nom, node));
                    }
                } catch (NullPointerException e) {}

                racine.add(lecteur);

            }

            //On crée, avec notre hiérarchie, un arbre
            jTreeSourceLocal = new javax.swing.JTree(racine);
            jPanelFTP = new javax.swing.JPanel();
            jScrollPane2 = new javax.swing.JScrollPane();
            jTreeSourceFTP = new javax.swing.JTree();
            jLabel3 = new javax.swing.JLabel();
            jTextField1 = new javax.swing.JTextField();
            jLabel4 = new javax.swing.JLabel();
            jTextField2 = new javax.swing.JTextField();
            jLabel5 = new javax.swing.JLabel();
            jPasswordField1 = new javax.swing.JPasswordField();
            jButton1 = new javax.swing.JButton();
            jLabel6 = new javax.swing.JLabel();
            jTextField3 = new javax.swing.JTextField();
            jPanelTCP = new javax.swing.JPanel();
            jScrollPane3 = new javax.swing.JScrollPane();
            jTreeSourceTCPIP = new javax.swing.JTree();
            jLabel7 = new javax.swing.JLabel();
            jTextField4 = new javax.swing.JTextField();
            jLabel8 = new javax.swing.JLabel();
            jTextField5 = new javax.swing.JTextField();
            jButton3 = new javax.swing.JButton();
            jPanelHTTP = new javax.swing.JPanel();
            jLabel15 = new javax.swing.JLabel();
            jTextField11 = new javax.swing.JTextField();
            jLabel1 = new javax.swing.JLabel();
            jLabel2 = new javax.swing.JLabel();
            jButton2 = new javax.swing.JButton();
            JTBCible = new javax.swing.JTabbedPane();
            jPanel6 = new javax.swing.JPanel();
            jScrollPane4 = new javax.swing.JScrollPane();
            DefaultMutableTreeNode racine1 = new DefaultMutableTreeNode();
            int count2 = 0;

            for(File file : File.listRoots()) {

                String f= file.getAbsolutePath();
                DefaultMutableTreeNode lecteur1 = new DefaultMutableTreeNode(f);
                System.out.println(f);
                //if(f.equals(s)){

                    try {
                        for(File nom : file.listFiles()){

                            DefaultMutableTreeNode node = new DefaultMutableTreeNode(nom.getName()+File.separator);
                            lecteur1.add(listFile(nom, node));
                        }
                    } catch (NullPointerException e) {}

                    racine1.add(lecteur1);

                }

                //On crée, avec notre hiérarchie, un arbre
                jTreeCibleLocal = new javax.swing.JTree(racine1);
                jPanel10 = new javax.swing.JPanel();
                jScrollPane5 = new javax.swing.JScrollPane();
                jTreeCibleFTP = new javax.swing.JTree();
                jLabel9 = new javax.swing.JLabel();
                jTextField6 = new javax.swing.JTextField();
                jLabel10 = new javax.swing.JLabel();
                jTextField7 = new javax.swing.JTextField();
                jLabel11 = new javax.swing.JLabel();
                jPasswordField2 = new javax.swing.JPasswordField();
                jButton4 = new javax.swing.JButton();
                jLabel12 = new javax.swing.JLabel();
                jTextField8 = new javax.swing.JTextField();
                jPanel11 = new javax.swing.JPanel();
                jScrollPane6 = new javax.swing.JScrollPane();
                jTreeCibleTCPIP = new javax.swing.JTree();
                jLabel13 = new javax.swing.JLabel();
                jTextField9 = new javax.swing.JTextField();
                jLabel14 = new javax.swing.JLabel();
                jTextField10 = new javax.swing.JTextField();
                jButton5 = new javax.swing.JButton();
                jPanel12 = new javax.swing.JPanel();
                jMenuBar1 = new javax.swing.JMenuBar();
                jMenu1 = new javax.swing.JMenu();
                jMenu2 = new javax.swing.JMenu();

                setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
                setTitle("Universalcopy");
                setName("Universalcopy"); // NOI18N

                jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);

                jTreeSourceLocal.setRootVisible(false);
                jTreeSourceLocal.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
                jTreeSourceLocal.setToggleClickCount(1);
                jTreeSourceLocal.addTreeSelectionListener( new TreeSelectionListener() {

                    public void valueChanged(TreeSelectionEvent e) {
                        if(jTreeSourceLocal.getLastSelectedPathComponent() != null){
                            /*javax.swing.tree.TreePath path = jTreeSourceLocal.getSelectionPath();
                            int pathCount = path.getPathCount();
                            System.out.println(path.toString());
                            System.out.println("Nombre de chemin : " + pathCount);

                            Object elements[] = path.getPath();
                            for (int i = 1, n = elements.length; i < n; i++) {
                                System.out.print(elements[i]);
                            }  */
                        }
                    }
                } );
                jScrollPane1.setViewportView(jTreeSourceLocal);

                javax.swing.GroupLayout jPanelLocalLayout = new javax.swing.GroupLayout(jPanelLocal);
                jPanelLocal.setLayout(jPanelLocalLayout);
                jPanelLocalLayout.setHorizontalGroup(
                    jPanelLocalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 368, Short.MAX_VALUE)
                );
                jPanelLocalLayout.setVerticalGroup(
                    jPanelLocalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 542, Short.MAX_VALUE)
                );

                JTBSource.addTab("Copie locale", jPanelLocal);

                jScrollPane2.setViewportView(jTreeSourceFTP);

                jLabel3.setText("Adressse du serveur FTP :");

                jLabel4.setText("Identifiant :");

                jLabel5.setText("Mot de passe :");

                jButton1.setText("Se connecter au serveur");
                jButton1.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jButton1ActionPerformed(evt);
                    }
                });

                jLabel6.setText("Port :");

                jTextField3.setText("21");

                javax.swing.GroupLayout jPanelFTPLayout = new javax.swing.GroupLayout(jPanelFTP);
                jPanelFTP.setLayout(jPanelFTPLayout);
                jPanelFTPLayout.setHorizontalGroup(
                    jPanelFTPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2)
                    .addGroup(jPanelFTPLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanelFTPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanelFTPLayout.createSequentialGroup()
                                .addGroup(jPanelFTPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jTextField1)
                                    .addGroup(jPanelFTPLayout.createSequentialGroup()
                                        .addGroup(jPanelFTPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(jPanelFTPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                                .addComponent(jLabel3)
                                                .addComponent(jLabel4)
                                                .addComponent(jTextField2)
                                                .addComponent(jLabel5)
                                                .addComponent(jPasswordField1, javax.swing.GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE))
                                            .addComponent(jLabel6)
                                            .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGap(0, 0, Short.MAX_VALUE)))
                                .addContainerGap())
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelFTPLayout.createSequentialGroup()
                                .addGap(0, 100, Short.MAX_VALUE)
                                .addComponent(jButton1)
                                .addGap(64, 64, 64))))
                );
                jPanelFTPLayout.setVerticalGroup(
                    jPanelFTPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelFTPLayout.createSequentialGroup()
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton1)
                        .addContainerGap(16, Short.MAX_VALUE))
                );

                JTBSource.addTab("FTP", jPanelFTP);

                jScrollPane3.setViewportView(jTreeSourceTCPIP);

                jLabel7.setText("Adresse du serveur distant :");

                jLabel8.setText("Port :");

                jButton3.setText("Se connecter au serveur");
                jButton3.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jButton3ActionPerformed(evt);
                    }
                });

                javax.swing.GroupLayout jPanelTCPLayout = new javax.swing.GroupLayout(jPanelTCP);
                jPanelTCP.setLayout(jPanelTCPLayout);
                jPanelTCPLayout.setHorizontalGroup(
                    jPanelTCPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane3)
                    .addGroup(jPanelTCPLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanelTCPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanelTCPLayout.createSequentialGroup()
                                .addGroup(jPanelTCPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jTextField4)
                                    .addGroup(jPanelTCPLayout.createSequentialGroup()
                                        .addGroup(jPanelTCPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel7)
                                            .addComponent(jLabel8)
                                            .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGap(0, 0, Short.MAX_VALUE)))
                                .addContainerGap())
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelTCPLayout.createSequentialGroup()
                                .addGap(0, 108, Short.MAX_VALUE)
                                .addComponent(jButton3)
                                .addGap(56, 56, 56))))
                );
                jPanelTCPLayout.setVerticalGroup(
                    jPanelTCPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelTCPLayout.createSequentialGroup()
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 372, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel8)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton3)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                );

                JTBSource.addTab("TCP/IP", jPanelTCP);

                jLabel15.setText("Adresse du fichier à télécharger :");

                jTextField11.setMaximumSize(new java.awt.Dimension(10, 28));

                javax.swing.GroupLayout jPanelHTTPLayout = new javax.swing.GroupLayout(jPanelHTTP);
                jPanelHTTP.setLayout(jPanelHTTPLayout);
                jPanelHTTPLayout.setHorizontalGroup(
                    jPanelHTTPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelHTTPLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanelHTTPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel15, javax.swing.GroupLayout.DEFAULT_SIZE, 344, Short.MAX_VALUE)
                            .addGroup(jPanelHTTPLayout.createSequentialGroup()
                                .addComponent(jTextField11, javax.swing.GroupLayout.PREFERRED_SIZE, 334, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 0, Short.MAX_VALUE)))
                        .addContainerGap())
                );
                jPanelHTTPLayout.setVerticalGroup(
                    jPanelHTTPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelHTTPLayout.createSequentialGroup()
                        .addGap(13, 13, 13)
                        .addComponent(jLabel15)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jTextField11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(471, Short.MAX_VALUE))
                );

                JTBSource.addTab("HTTP", jPanelHTTP);

                jLabel1.setText("Sélectionnez le fichier source :");

                jLabel2.setText("Sélectionnez le dossier cible :");

                jButton2.setText("Lancer la copie");
                jButton2.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jButton2ActionPerformed(evt);
                    }
                });

                jTreeCibleLocal.setRootVisible(false);
                jTreeCibleLocal.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
                jTreeCibleLocal.setToggleClickCount(1);
                jTreeCibleLocal.addTreeSelectionListener( new TreeSelectionListener() {

                    public void valueChanged(TreeSelectionEvent e) {
                        if(jTreeCibleLocal.getLastSelectedPathComponent() != null){
                            /*javax.swing.tree.TreePath path = jTreeCibleLocal.getSelectionPath();
                            int pathCount = path.getPathCount();
                            System.out.println(path.toString());
                            System.out.println("Nombre de chemin : " + pathCount);

                            Object elements[] = path.getPath();
                            for (int i = 1, n = elements.length; i < n; i++) {
                                System.out.print(elements[i]);
                            } */
                        }
                    }
                } );
                jScrollPane4.setViewportView(jTreeCibleLocal);

                javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
                jPanel6.setLayout(jPanel6Layout);
                jPanel6Layout.setHorizontalGroup(
                    jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 368, Short.MAX_VALUE)
                );
                jPanel6Layout.setVerticalGroup(
                    jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 566, Short.MAX_VALUE)
                );

                JTBCible.addTab("Copie locale", jPanel6);

                jScrollPane5.setViewportView(jTreeCibleFTP);

                jLabel9.setText("Adressse du serveur FTP :");

                jLabel10.setText("Identifiant :");

                jLabel11.setText("Mot de passe :");

                jButton4.setText("Se connecter au serveur");
                jButton4.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jButton4ActionPerformed(evt);
                    }
                });

                jLabel12.setText("Port :");

                javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
                jPanel10.setLayout(jPanel10Layout);
                jPanel10Layout.setHorizontalGroup(
                    jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane5)
                    .addGroup(jPanel10Layout.createSequentialGroup()
                        .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel10Layout.createSequentialGroup()
                                .addContainerGap()
                                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jTextField6)
                                    .addGroup(jPanel10Layout.createSequentialGroup()
                                        .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                                .addComponent(jLabel9)
                                                .addComponent(jLabel10)
                                                .addComponent(jTextField7)
                                                .addComponent(jLabel11)
                                                .addComponent(jPasswordField2, javax.swing.GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE))
                                            .addComponent(jLabel12)
                                            .addComponent(jTextField8, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGap(0, 0, Short.MAX_VALUE))))
                            .addGroup(jPanel10Layout.createSequentialGroup()
                                .addGap(63, 63, 63)
                                .addComponent(jButton4)
                                .addGap(0, 101, Short.MAX_VALUE)))
                        .addContainerGap())
                );
                jPanel10Layout.setVerticalGroup(
                    jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel10Layout.createSequentialGroup()
                        .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel9)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel10)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextField7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel11)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPasswordField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel12)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextField8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButton4)
                        .addContainerGap(34, Short.MAX_VALUE))
                );

                JTBCible.addTab("FTP", jPanel10);

                jScrollPane6.setViewportView(jTreeCibleTCPIP);

                jLabel13.setText("Adresse du serveur distant :");

                jLabel14.setText("Port :");

                jButton5.setText("Se connecter au serveur");
                jButton5.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jButton5ActionPerformed(evt);
                    }
                });

                javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11);
                jPanel11.setLayout(jPanel11Layout);
                jPanel11Layout.setHorizontalGroup(
                    jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane6)
                    .addGroup(jPanel11Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel11Layout.createSequentialGroup()
                                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jTextField9)
                                    .addGroup(jPanel11Layout.createSequentialGroup()
                                        .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel13)
                                            .addComponent(jLabel14)
                                            .addComponent(jTextField10, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGap(0, 0, Short.MAX_VALUE)))
                                .addContainerGap())
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel11Layout.createSequentialGroup()
                                .addGap(0, 108, Short.MAX_VALUE)
                                .addComponent(jButton5)
                                .addGap(56, 56, 56))))
                );
                jPanel11Layout.setVerticalGroup(
                    jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel11Layout.createSequentialGroup()
                        .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 372, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel13)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextField9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel14)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextField10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton5)
                        .addContainerGap(30, Short.MAX_VALUE))
                );

                JTBCible.addTab("TCP/IP", jPanel11);

                javax.swing.GroupLayout jPanel12Layout = new javax.swing.GroupLayout(jPanel12);
                jPanel12.setLayout(jPanel12Layout);
                jPanel12Layout.setHorizontalGroup(
                    jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGap(0, 368, Short.MAX_VALUE)
                );
                jPanel12Layout.setVerticalGroup(
                    jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGap(0, 566, Short.MAX_VALUE)
                );

                JTBCible.addTab("HTTP", jPanel12);

                javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
                jPanel1.setLayout(jPanel1Layout);
                jPanel1Layout.setHorizontalGroup(
                    jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel1)
                                    .addComponent(JTBSource, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(18, 18, 18)
                                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGap(6, 6, 6)
                                        .addComponent(jLabel2)
                                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                    .addComponent(JTBCible, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                .addGap(0, 0, Short.MAX_VALUE)
                                .addComponent(jButton2)
                                .addGap(290, 290, 290))))
                );
                jPanel1Layout.setVerticalGroup(
                    jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(18, 18, 18)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(jLabel2)
                                        .addGap(12, 12, 12)
                                        .addComponent(JTBCible, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(jLabel1)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(JTBSource, javax.swing.GroupLayout.PREFERRED_SIZE, 586, javax.swing.GroupLayout.PREFERRED_SIZE))))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(23, 23, 23)
                                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 611, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton2)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                );

                jMenu1.setText("File");
                jMenuBar1.add(jMenu1);

                jMenu2.setText("Edit");
                jMenuBar1.add(jMenu2);

                setJMenuBar(jMenuBar1);

                javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
                getContentPane().setLayout(layout);
                layout.setHorizontalGroup(
                    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 22, Short.MAX_VALUE))
                );
                layout.setVerticalGroup(
                    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                );

                pack();
            }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        
        String message = "";
        try {
            System.out.println("Se connecter au serveur FTP de la source");
            throw new NotYetImplementedException("La fonction de connexion à un serveur ftp source n'est pas disponible.");
        }
        
        catch (NotYetImplementedException e) { message = e.getMessage(); e.printStackTrace(); }
        
        finally {
            javax.swing.JOptionPane.showMessageDialog(Launcher.getInstance(), message, "Information", javax.swing.JOptionPane.WARNING_MESSAGE);
        }
        
    }//GEN-LAST:event_jButton1ActionPerformed

    /**
     * Method for the clic event on the "Lancer la copie" button
     * @param evt
     */
    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {  
            
        System.out.println("Lancer la copie");
        
        String message = "";
        
        boolean isError = false;
        
        try {
        
            String titreTabSource = this.getJTBSource().getTitleAt(this.getJTBSource().getSelectedIndex());
            String titreTabCible = this.getJTBCible().getTitleAt(this.getJTBCible().getSelectedIndex());

            String cheminSource = "";
            String cheminCible = "";

            boolean sourceIsLocal = false;
            boolean cibleIsLocal = false;

            /* Contains informations about remote servers
             * [0] -> type of connection
             * [1] -> file's path on the remote server
             * [2] -> remote server address
             * [3] -> login
             * [4] -> password
             * [5] -> port number
             */
            String[] infoSourceDistant = new String[6];
            String[] infoCibleDistant = new String[6];

            
            // Recovery following the path of the selected tree for the source
            if(titreTabSource.equalsIgnoreCase("copie locale")) {
                cheminSource = this.findTreePath(this.getJTreeSourceLocal());
                sourceIsLocal = true;
            }
            else if(titreTabSource.equalsIgnoreCase("ftp")) {
                System.out.println("Source FTP");
                cheminSource = this.findTreePath(this.getJTreeSourceFTP());
                infoSourceDistant[0] = "ftp";
                infoSourceDistant[1] = cheminSource;
                infoSourceDistant[2] = this.jTextField1.getText();
                infoSourceDistant[3] = this.jTextField2.getText();
                infoSourceDistant[4] = this.jPasswordField1.getText();
                infoSourceDistant[5] = this.jTextField3.getText();
                throw new NotYetImplementedException("La copie à partir d'une source ftp n'est pas disponible !");
            
            }
            else if(titreTabSource.equalsIgnoreCase("tcp/ip")) {
                cheminSource = this.findTreePath(this.getJTreeSourceTCPIP());
                throw new NotYetImplementedException("La copie à partir d'une source tcp/ip n'est pas disponible !");
            }
            else {
                if(!titreTabCible.equalsIgnoreCase("copie locale")){
                    throw new HTTPCompatibilityException();
                
                } else {
                    cheminSource = this.jTextField11.getText();
                    infoSourceDistant[0] = "http";
                    infoSourceDistant[1] = this.jTextField11.getText();
                }
            }

             // Recovery following the path of the selected tree for the target
            if(titreTabCible.equalsIgnoreCase("copie locale")) {
                cheminCible = this.findTreePath(this.getJTreeCibleLocal());
                cibleIsLocal = true;
            }
            else if(titreTabCible.equalsIgnoreCase("ftp")) {
                //cheminCible = this.findTreePath(this.getJTreeCibleFTP());
                infoCibleDistant[0] = "ftp";
                infoCibleDistant[1] = cheminCible;
                infoCibleDistant[2] = this.jTextField6.getText();
                infoCibleDistant[3] = this.jTextField7.getText();
                infoCibleDistant[4] = this.jPasswordField2.getText();
                infoCibleDistant[5] = this.jTextField8.getText();
                throw new NotYetImplementedException("La copie vers une cible ftp n'est pas disponible !");
            
            }
            else if(titreTabCible.equalsIgnoreCase("tcp/ip")) {
                cheminCible = this.findTreePath(this.getJTreeCibleTCPIP());
                throw new NotYetImplementedException("La copie vers une cible tcp/ip n'est pas disponible !");
            
            }
            else {
                throw new NotYetImplementedException("La copie vers une cible http n'est pas disponible !");
            
            }


            Transfer t;

            // Creation of the object type transfer depending on the type of the requested copy
            if(sourceIsLocal && cibleIsLocal) {
                t = new Transfer(cheminSource, cheminCible);
            }
            else if (sourceIsLocal && !cibleIsLocal) {
                t = new Transfer(cheminSource, infoCibleDistant );
            }
            else if( !sourceIsLocal && cibleIsLocal ) {
                t = new Transfer(infoSourceDistant, cheminCible);
            }
            else {
                t = new Transfer(infoSourceDistant, infoCibleDistant);
            }

            // Launch transfert
            t.runTransfer();

            
            message = "La copie de  :\n\t"+ cheminSource + "\nvers :\n\t" + cheminCible + "\n a été effectuée avec succès !";

            
            
        }
        
        catch (NotYetImplementedException nyie) { isError = true; message = nyie.getMessage(); nyie.printStackTrace(); }
                  
        catch (HTTPCompatibilityException httpce) { isError = true; message = httpce.getMessage(); httpce.printStackTrace(); }
        
        catch (SourceTargetForTreeException stfte) { isError = true; message = stfte.getMessage(); stfte.printStackTrace(); }
        
        catch (Exception e) { isError = true; message = "Une erreur est survenu lors de la copie !"; e.printStackTrace(); }
        
        finally {
            
            if(isError) {
                javax.swing.JOptionPane.showMessageDialog(Launcher.getInstance(), message, "Une erreur est survenu", javax.swing.JOptionPane.ERROR_MESSAGE);
            } else {
                
                java.io.File file = new java.io.File("");
                
                try {
                    System.out.println(file.getAbsolutePath());
                    //final javax.swing.ImageIcon icon = new javax.swing.ImageIcon(file.getAbsolutePath() + java.io.File.separator + "src" + java.io.File.separator + "logo-ok.png");
                    
                    final javax.swing.ImageIcon icon = new javax.swing.ImageIcon(file.getAbsolutePath() + java.io.File.separator + "src" + java.io.File.separator +"images" + java.io.File.separator + "logo-ok.png");
                    
                    javax.swing.JOptionPane.showMessageDialog(Launcher.getInstance(), message, "Synthèse de la copie demandée", javax.swing.JOptionPane.INFORMATION_MESSAGE, icon);
                } catch (Exception e) {
                    javax.swing.JOptionPane.showMessageDialog(Launcher.getInstance(), message, "Synthèse de la copie demandée", javax.swing.JOptionPane.INFORMATION_MESSAGE);
                
                }
               
            }
                
        }
        
        
        
        
    }  
    
    
    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
        
        String message = "";
        try {
            System.out.println("Se connecter au serveur source TCP/IP");
            throw new NotYetImplementedException("La fonction de connexion à un serveur tcp/ip source n'est pas disponible.");
        }
        
        catch (NotYetImplementedException e) { message = e.getMessage(); e.printStackTrace(); }
        
        finally {
            javax.swing.JOptionPane.showMessageDialog(Launcher.getInstance(), message, "Information", javax.swing.JOptionPane.WARNING_MESSAGE);
        }
        
    } 
    
    
    
    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        // TODO add your handling code here:
        
        String message = "";
        try {
            System.out.println("Se connecter au serveur cible FTP");
            throw new NotYetImplementedException("La fonction de connexion à un serveur ftp cible n'est pas disponible.");
        }
        
        catch (NotYetImplementedException e) { message = e.getMessage(); e.printStackTrace(); }
        
        finally {
            javax.swing.JOptionPane.showMessageDialog(Launcher.getInstance(), message, "Information", javax.swing.JOptionPane.WARNING_MESSAGE);
        }
        
        
    }//GEN-LAST:event_jButton4ActionPerformed

    
    
    
    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
        String message = "";
        try {
            System.out.println("Se connecter au serveur cible TCP/IP");
            throw new NotYetImplementedException("La fonction de connexion à un serveur tcp/ip cible n'est pas disponible.");
        }
        
        catch (NotYetImplementedException e) { message = e.getMessage(); e.printStackTrace(); }
        
        finally {
            javax.swing.JOptionPane.showMessageDialog(Launcher.getInstance(), message, "Information", javax.swing.JOptionPane.WARNING_MESSAGE);
        
        }
    } 
    
    
    
    /**
     * Private method for the tree generation
     * @param file
     * @param node
     * @return 
     */
    private static DefaultMutableTreeNode listFile(File file, DefaultMutableTreeNode node){
        int count = 0;
        if(file.isFile())
            return new DefaultMutableTreeNode(file.getName());
        else{
            for(File nom : file.listFiles()){
                DefaultMutableTreeNode subNode;
                if(nom.isDirectory()){
                    subNode = new DefaultMutableTreeNode(nom.getName()+ java.io.File.separator);
                    node.add(listFile(nom, subNode));
                }else{
                    subNode = new DefaultMutableTreeNode(nom.getName());
                }

                node.add(subNode);

            }
            return node;
        }
    }
    
    
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Launcher.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Launcher.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Launcher.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Launcher.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Launcher().setVisible(true);
               
            }
        });
    }
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTabbedPane JTBCible;
    private javax.swing.JTabbedPane JTBSource;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel12;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanelFTP;
    private javax.swing.JPanel jPanelHTTP;
    private javax.swing.JPanel jPanelLocal;
    private javax.swing.JPanel jPanelTCP;
    private javax.swing.JPasswordField jPasswordField1;
    private javax.swing.JPasswordField jPasswordField2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField10;
    private javax.swing.JTextField jTextField11;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JTextField jTextField5;
    private javax.swing.JTextField jTextField6;
    private javax.swing.JTextField jTextField7;
    private javax.swing.JTextField jTextField8;
    private javax.swing.JTextField jTextField9;
    private javax.swing.JTree jTreeCibleFTP;
    private javax.swing.JTree jTreeCibleLocal;
    private javax.swing.JTree jTreeCibleTCPIP;
    private javax.swing.JTree jTreeSourceFTP;
    private javax.swing.JTree jTreeSourceLocal;
    private javax.swing.JTree jTreeSourceTCPIP;
    // End of variables declaration//GEN-END:variables

    
    private static Launcher launcher;
    
    /**
     * Used to retrieve the current instance of the window UniversalCopy (Singleton Pattern)
     * @return launcher : the instance of the universalcopy window
     */
    public static Launcher getInstance() {
        
        return launcher;
    }
    
    
    

    /* Creating get and set methods for recovery of graphical objects in listeners */

    /**
     * Returns the selected tab (target side)
     * @return JTBCible
     */
    public javax.swing.JTabbedPane getJTBCible() {
        return this.JTBCible;
    }

    
    /**
     * Returns the selected tab (source side)
     * @return JTBSource
     */
    public javax.swing.JTabbedPane getJTBSource() {
        return this.JTBSource;
    }

    /**
     * Returns the tree of local (source side)
     * @return jTreeSourceLocal
     */
    public javax.swing.JTree getJTreeSourceLocal() {
        return this.jTreeSourceLocal;
    }
    
    
    /**
     * Returns the tree of ftp (source side)
     * @return jTreeSourceFTP
     */
    public javax.swing.JTree getJTreeSourceFTP() {
        return this.jTreeSourceFTP;
    }
    
    
    /**
     * Returns the tree of TCP/IP (source side)
     * @return jTreeSourceTCPIP
     */
    public javax.swing.JTree getJTreeSourceTCPIP() {
        return this.jTreeSourceTCPIP;
    }
    
    
    /**
     * Returns the tree of local (target side)
     * @return jTreeCibleLocal
     */
    public javax.swing.JTree getJTreeCibleLocal() {
        return this.jTreeCibleLocal;
    }
    
    
    /**
     * Returns the tree of ftp (target side)
     * @return jTreeCibleFTP
     */
    public javax.swing.JTree getJTreeCibleFTP() {
        return this.jTreeCibleFTP;
    }
    
    
    /**
     * Returns the tree of tcp/ip (target side)
     * @return jTreeCibleTCPIP
     */
    public javax.swing.JTree getJTreeCibleTCPIP() {
        return this.jTreeCibleTCPIP;
    }
    
    
    /* Private methods */
    
    /**
     * Used to retrieve the path of the selected file in the tree
     * @param tree : the tree in which the file is selected
     * @return res : the file path
     * @throws SourceTargetForTreeException
     */
    private String findTreePath(javax.swing.JTree tree) throws SourceTargetForTreeException {
        
        String res = "";
        
        try {
            String os = System.getProperty("os.name").toLowerCase();

            javax.swing.tree.TreePath path = tree.getSelectionPath();
            //int pathCount = path.getPathCount();
            //System.out.println(path.toString());
            //System.out.println("Nombre de chemin : " + pathCount);

            Object elements[] = path.getPath();  
            for (int i = 1, n = elements.length; i < n; i++) {  
                res += elements[i];  
            }
            
        } catch(Exception e) {
            
            //Launcher l = Launcher.getInstance();
            //javax.swing.JOptionPane.showMessageDialog(l, "Veuillez sélectionner une source et une cible.");
            throw new SourceTargetForTreeException();
            
        } finally {
            
            return res;
        }
        
        
    }
    
}
